package com.flink.hbase.doris.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 用户事件数据模型
 * 对应Doris表中的用户行为数据
 */
public class UserEvent implements Serializable {
    
    @JsonProperty("event_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime eventTime;
    
    @JsonProperty("user_id")
    private Long userId;
    
    @JsonProperty("event_type")
    private String eventType;
    
    @JsonProperty("page_url")
    private String pageUrl;
    
    @JsonProperty("device_type")
    private String deviceType;
    
    @JsonProperty("browser")
    private String browser;
    
    @JsonProperty("os")
    private String os;
    
    @JsonProperty("ip_address")
    private String ipAddress;
    
    @JsonProperty("country")
    private String country;
    
    @JsonProperty("city")
    private String city;
    
    @JsonProperty("pv")
    private Long pv;
    
    @JsonProperty("duration")
    private Long duration;
    
    /**
     * 默认构造函数
     */
    public UserEvent() {}
    
    /**
     * 构造函数
     * @param eventTime 事件时间
     * @param userId 用户ID
     * @param eventType 事件类型
     * @param pageUrl 页面URL
     */
    public UserEvent(LocalDateTime eventTime, Long userId, String eventType, String pageUrl) {
        this.eventTime = eventTime;
        this.userId = userId;
        this.eventType = eventType;
        this.pageUrl = pageUrl;
        this.pv = 1L;
        this.duration = 0L;
    }
    
    // Getters and Setters
    public LocalDateTime getEventTime() { return eventTime; }
    public void setEventTime(LocalDateTime eventTime) { this.eventTime = eventTime; }
    
    public Long getUserId() { return userId; }
    public void setUserId(Long userId) { this.userId = userId; }
    
    public String getEventType() { return eventType; }
    public void setEventType(String eventType) { this.eventType = eventType; }
    
    public String getPageUrl() { return pageUrl; }
    public void setPageUrl(String pageUrl) { this.pageUrl = pageUrl; }
    
    public String getDeviceType() { return deviceType; }
    public void setDeviceType(String deviceType) { this.deviceType = deviceType; }
    
    public String getBrowser() { return browser; }
    public void setBrowser(String browser) { this.browser = browser; }
    
    public String getOs() { return os; }
    public void setOs(String os) { this.os = os; }
    
    public String getIpAddress() { return ipAddress; }
    public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; }
    
    public String getCountry() { return country; }
    public void setCountry(String country) { this.country = country; }
    
    public String getCity() { return city; }
    public void setCity(String city) { this.city = city; }
    
    public Long getPv() { return pv; }
    public void setPv(Long pv) { this.pv = pv; }
    
    public Long getDuration() { return duration; }
    public void setDuration(Long duration) { this.duration = duration; }
    
    @Override
    public String toString() {
        return "UserEvent{" +
                "eventTime=" + eventTime +
                ", userId=" + userId +
                ", eventType='" + eventType + '\'' +
                ", pageUrl='" + pageUrl + '\'' +
                ", deviceType='" + deviceType + '\'' +
                ", browser='" + browser + '\'' +
                ", os='" + os + '\'' +
                ", ipAddress='" + ipAddress + '\'' +
                ", country='" + country + '\'' +
                ", city='" + city + '\'' +
                ", pv=" + pv +
                ", duration=" + duration +
                '}';
    }
    
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        
        UserEvent userEvent = (UserEvent) o;
        
        if (eventTime != null ? !eventTime.equals(userEvent.eventTime) : userEvent.eventTime != null) return false;
        if (userId != null ? !userId.equals(userEvent.userId) : userEvent.userId != null) return false;
        if (eventType != null ? !eventType.equals(userEvent.eventType) : userEvent.eventType != null) return false;
        return pageUrl != null ? pageUrl.equals(userEvent.pageUrl) : userEvent.pageUrl == null;
    }
    
    @Override
    public int hashCode() {
        int result = eventTime != null ? eventTime.hashCode() : 0;
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        result = 31 * result + (eventType != null ? eventType.hashCode() : 0);
        result = 31 * result + (pageUrl != null ? pageUrl.hashCode() : 0);
        return result;
    }
} 